//
//  WoDeViewController.m
//  XiangMu
//
//  Created by   on 15/7/13.
//  Copyright (c) 2015年  康世标. All rights reserved.
//

#import "WoDeViewController.h"

@interface WoDeViewController ()

@end

@implementation WoDeViewController
- (void)viewWillAppear:(BOOL)animated{
    
    self.tabBarController.tabBar.hidden = NO;
    [self.tableview reloadData];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
  
    UIColor * color = [UIColor whiteColor];
    NSDictionary * dict=[NSDictionary dictionaryWithObject:color forKey:NSForegroundColorAttributeName];
    
    self.navigationController.navigationBar.titleTextAttributes = dict;
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage
                                                                 imageNamed:@"dianchiliang"] forBarMetrics:UIBarMetricsDefault];
    [self.tableview registerNib:[UINib nibWithNibName:@"GeRenableViewCell" bundle:nil] forCellReuseIdentifier:@"geren"];
    
    [self.tableview registerNib:[UINib nibWithNibName:@"YongHuPingjIaTableViewCell" bundle:nil] forCellReuseIdentifier:@"er"];
    

    _imagsArr=[[NSArray alloc]initWithObjects:@"open-book1",@"tubiaofenxiang",@"telephone1",@"clipboard-2",@"guanyuwomen",@"settings", nil];
    _textArr=[[NSArray alloc]initWithObjects:@"帮助手册",@"应用分享",@"客服电话",@"意见反馈",@"关于我们",@"系统设置", nil];
    
    
}
#pragma mark--UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section==0) {
        
        return 1;
    }
    else if (section==1){
        return 4;
    }
    else{
        return 2;
    }
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
   
    if (indexPath.section==0) {
        
        GeRenableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"geren" forIndexPath:indexPath];
        
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        [cell.geRenBtn addTarget:self action:@selector(geRenBtnZiLiao) forControlEvents:UIControlEventTouchUpInside];
        [cell.dingDanBtn addTarget:self action:@selector(dingDanBtnBtnZiLiao) forControlEvents:UIControlEventTouchUpInside];
        [cell.shouCangBtn addTarget:self action:@selector(shouCangBtnZiLiao) forControlEvents:UIControlEventTouchUpInside];
        [cell.youHuiBtn addTarget:self action:@selector(youHuiBtnZiLiao) forControlEvents:UIControlEventTouchUpInside];
        [cell.yiFaBu addTarget:self action:@selector(YiFabuBtnClock) forControlEvents:UIControlEventTouchUpInside];
        
        
        //用户头像
        [cell.hedImagView sd_setImageWithURL:[NSURL URLWithString:[[NSUserDefaults standardUserDefaults] objectForKey:@"headImg"]] placeholderImage:[UIImage imageNamed:@"like"]];
        cell.name.text = [[NSUserDefaults standardUserDefaults]objectForKey:@"nickname"];
        
        return cell;
    }
    else{
        YongHuPingjIaTableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"er" forIndexPath:indexPath];
        cell.lable2.hidden=YES;
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

        if (indexPath.section==1) {
            cell.imagView1.image=[UIImage imageNamed:[_imagsArr objectAtIndex:indexPath.row]];
            cell.lable1.text=[_textArr objectAtIndex:indexPath.row];
        }
        else{
            cell.imagView1.image=[UIImage imageNamed:[_imagsArr objectAtIndex:indexPath.row+4]];
            cell.lable1.text=[_textArr objectAtIndex:indexPath.row+4];
        }
        
        return cell;
    }
  
    
}
#pragma mark--UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        return 200;
    }
    
    return 45;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section==0) {
        return 0;
    }
    return 0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section==1) {
        switch (indexPath.row) {
            case 0:
            {
                BangZhuShouCeViewController*b=[[BangZhuShouCeViewController alloc]init];
                [self.navigationController pushViewController:b animated:YES];
            }
                break;
            case 1:
           {


              KSActionSheet *sheet=[[KSActionSheet alloc]initWithActionSheet];
               sheet.delegate=self;
               
//               self.tabBarController.tabBar.hidden=YES;
               [sheet show];
               
            }
                break;
                
            case 2:
            {
                 UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@"您确定要拨打电话吗?" message:KFDH delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
                [alert show];
            }
                break;
                
            case 3:
            {
                YiJianFanKuiViewController*y=[[YiJianFanKuiViewController alloc]init];
                [self.navigationController pushViewController:y animated:YES];
                
            }
                break;
                
  
            default:
                break;
        }
    }
    
    if (indexPath.section==2) {
        
        switch (indexPath.row) {
            case 0:
            {
                //关于我们
                GuanYuWoMenViewController *g=[[GuanYuWoMenViewController alloc]init];
                g.title = @"关于我们";
                [self.navigationController pushViewController:g animated:YES];
            }
                break;
            case 1:
            {
                XiTongSheZhiViewController *x=[[XiTongSheZhiViewController alloc]init];
                [self.navigationController pushViewController:x animated:YES];
                
            }
                break;

            default:
                break;
        }
    }
    
}
#pragma mark--个人资料
-(void)geRenBtnZiLiao{
    GeRenViewController*g=[[GeRenViewController alloc]init];
    g.title=@"个人资料";
    
    [self.navigationController pushViewController:g animated:YES];
}
#pragma mark--我的订单
- (void)dingDanBtnBtnZiLiao{
    
    WoDeDingDanViewController *w=[[WoDeDingDanViewController alloc]init];
    w.title=@"我的订单";
    [self.navigationController pushViewController:w animated:YES];
    
}
#pragma mark -- 已发布订单
- (void)YiFabuBtnClock{
    
    HasBeenEeleased * has = [[HasBeenEeleased alloc]init];
    [self.navigationController pushViewController:has animated:YES];
    
}
#pragma mark--收藏
- (void)shouCangBtnZiLiao{
    
    ShouCangViewController *s = [[ShouCangViewController alloc]init];
    s.title = @"收藏";
    [self.navigationController pushViewController:s animated:YES];
    
    
}
#pragma mark--优惠劵
- (void)youHuiBtnZiLiao{
    
    YouHuiJuanViewController * y = [[YouHuiJuanViewController alloc]init];
    y.my = YES;
    
    [self.navigationController pushViewController:y animated:YES];
}
#pragma mark----
- (void)alertView:(KSActionSheet *)alertView clickedButtonAtIndexPantex:(NSInteger)buttonIndex{
    
    self.tabBarController.tabBar.hidden = NO;
    int i;
    
   if(buttonIndex==0)
   {
      
       return;

    }

    i= (int )buttonIndex-1;

                    WXMediaMessage *message = [WXMediaMessage message];
                    message.title = @"爱陪护";
                    message.description = @"爱陪护";
                    [message setThumbImage:[UIImage imageNamed:@"Image_Icon"]];
    
                    WXWebpageObject *ext = [WXWebpageObject object];
                    ext.webpageUrl = @"http://www.apeihu.cn/user/start";
    
                    message.mediaObject = ext;
    
                    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
                    req.bText = NO;
                    req.message = message;
                    req.scene = i;
    
                 BOOL isok=   [WXApi sendReq:req];

    if (!isok) {
        [[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"未安装微信客户端" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil] show];
        
    }
    
   
    
    
}
#pragma  mark ---UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    switch (buttonIndex) {
        case 0:
        {
            NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",HJKFDH];
            
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

        
        }
            break;
        case 1:
        {
            
        }
            break;

        default:
            break;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
